﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using LPV_POS.mh_pos.mh_cauhinh;
using LPV_POS.Module;
using System.Resources;
using System.Globalization;

namespace LPV_POS.mh_pos
{
    public partial class mh_chedocaidat : DevExpress.XtraEditors.XtraForm
    {
        CultureInfo culture;
        #region "Muti language"

        private void SetLanguage_banhang(string cultureName)
        {
            try
            {
                culture = CultureInfo.CreateSpecificCulture(cultureName);
                ResourceManager rm = new ResourceManager("LPV_POS.Muti_language.MyResource", typeof(mh_chedocaidat).Assembly);
                lbel_dsdanhmuc.Text = "1. " + rm.GetString("danhsachdanhmuc", culture);
                lbel_cauhinhban.Text = "2. " + rm.GetString("cauhinhsodoban", culture);
                lbel_cauhinhmenu_chucnang.Text = "3. " + rm.GetString("cauhinhmenuchucnang", culture);
                lblPhanQuyen.Text = "4. " + rm.GetString("phanquyen", culture);
                lbel_thoat.Text = "5. " + rm.GetString("thoat", culture);
                this.Text = rm.GetString("danhsachcaidat", culture);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Note");
            }

        }

        #endregion
        public mh_chedocaidat()
        {
            InitializeComponent();
            culture = CultureInfo.CurrentCulture;
        }

       
        private void lbel_dsdanhmuc_MouseDown(object sender, MouseEventArgs e)
        {
            
            lbel_dsdanhmuc.BackColor = Color.FromArgb(192,249,251);
            lbel_dsdanhmuc.BorderStyle = BorderStyle.Fixed3D;
        }

        private void lbel_dsdanhmuc_MouseUp(object sender, MouseEventArgs e)
        {
            lbel_dsdanhmuc.BackColor = Color.FromArgb(227, 241, 254);
            lbel_dsdanhmuc.BorderStyle = BorderStyle.None;
        }

        private void mh_chedocaidat_Load(object sender, EventArgs e)
        {
            cpublic ocpublic = new cpublic();
            string str_lang = ocpublic.Registry_Get("mh_main_lang");
            if (str_lang == "")
                str_lang = "vi-VN";
            SetLanguage_banhang(str_lang);
        }

        private void lbel_dsdanhmuc_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            mh_danhsachdanhmuc frm_danhsachdanhmu = new mh_danhsachdanhmuc();
            frm_danhsachdanhmu.Show();
            this.Cursor = Cursors.Default;
            this.Close();
        }

        private void lbel_cauhinh_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            mh_cauhinhbaocao frm_cauhinhbaocao = new mh_cauhinhbaocao();
            frm_cauhinhbaocao.Show();
            this.Cursor = Cursors.Default;
        }

        private void bton_thoat_Click(object sender, EventArgs e)
        {
            Mod_messagebox mess = new Mod_messagebox();
            mess.messagebox_pos("Thông báo", "Bạn muốn thoát?", loaithongbao.yesno.GetHashCode());
            if (Variable.thongbao == true)
            {

                this.Close();
            }
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {

        }

        private void lbel_thoat_Click(object sender, EventArgs e)
        {
            //Mod_messagebox mess = new Mod_messagebox();
            //mess.messagebox_pos("Thông báo", "Bạn muốn thoát?", loaithongbao.yesno.GetHashCode());
            //if (Variable.thongbao == true)
           
                this.Close();
            
        }

        private void lbel_cauhinhban_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            mh_dmkhuvuc omh_dmkhuvuc = new mh_dmkhuvuc();
            omh_dmkhuvuc.ShowInTaskbar = false;
            this.Cursor = Cursors.Default;
            omh_dmkhuvuc.ShowDialog();
            this.Dispose();
        }

        private void lbel_chuctrangchu_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            mh_cauhinhtrangchu frm_cauhinhtrangchu = new mh_cauhinhtrangchu();
            this.Cursor = Cursors.Default;
            frm_cauhinhtrangchu.ShowDialog();
            this.Dispose();
        }

        private void lbel_cauhinhmenu_chucnang_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            mh_cauhinh_menuchucnang omh_cauhinh_menuchucnang =new mh_cauhinh_menuchucnang();
            this.Cursor = Cursors.Default;
            omh_cauhinh_menuchucnang.ShowDialog();
            this.Dispose();
        }

        private void lblPhanQuyen_Click(object sender, EventArgs e)
        {
            if (new cpublic().KiemTra_CoQuyen(this.Name, lblPhanQuyen.Name, 1))
            {
                this.Cursor = Cursors.WaitCursor;
                mh_dangnhap_MENU omh_dangnhap_MENU = new mh_dangnhap_MENU();
                this.Cursor = Cursors.Default;
                omh_dangnhap_MENU.ShowDialog();
                this.Dispose();
            }
            else
            {
                string sSQL = "SELECT * FROM DM_DANGNHAP dd";
                DataTable tb = new thuvien().SP_SelectDataTable("SP_EXECUTESQL", new string[] { "@sSQL"}, new object[] { sSQL});
                if(tb!=null)
                    if (tb.Rows.Count == 0)
                    {
                        this.Cursor = Cursors.WaitCursor;
                        mh_dangnhap_MENU omh_dangnhap_MENU = new mh_dangnhap_MENU();
                        this.Cursor = Cursors.Default;
                        omh_dangnhap_MENU.ShowDialog();
                        this.Dispose();
                        return;
                    }
                sSQL = "";
                foreach (DataRow dr in tb.Rows)
                    sSQL += dr["USERNAME"] + "; ";
                MessageBox.Show("Bạn không có quyền", "Thông báo: "+sSQL);
            }
        }
    }
}